//
//  DiaryDetaiImgView.m
//  PSYWeiBo
//
//  Created by xiaotian on 16/3/17.
//  Copyright © 2016年 郑亚田. All rights reserved.
//

#import "DiaryDetaiImgView.h"

@implementation DiaryDetaiImgView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addAllViews];
    }
    return self;
}

- (void)addAllViews {
    self.image = [UIImage imageNamed:@"letter-paper1-1"];
//    self.userInteractionEnabled = YES;
    
    UIImageView *bgrImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"diary-header-bg"]];
    bgrImg.userInteractionEnabled = YES;
    [self addSubview:bgrImg];
    [bgrImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.left.equalTo(@20);
        make.right.equalTo(@-20);
        make.height.equalTo(@((kScreenWidth - 40) * 0.25));
    }];
    
    UIImageView *diaryCalBgrImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"diary-calendar-bg"]];
    [bgrImg addSubview:diaryCalBgrImg];
    [diaryCalBgrImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@2);
        make.top.equalTo(@1);
        make.bottom.equalTo(@-1);
        make.width.equalTo(bgrImg.mas_height);
    }];
    
    CGFloat imgHeight = diaryCalBgrImg.frame.size.height;
    UILabel *month = [UILabel new];
    [diaryCalBgrImg addSubview:month];
    [month mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.height.equalTo(@(imgHeight * 0.25));
    }];
    month.textAlignment = NSTextAlignmentCenter;
    month.font = [UIFont systemFontOfSize:10];
    month.text = @"三月";
    self.monthLab = month;
    
    UILabel *date = [UILabel new];
    [diaryCalBgrImg addSubview:date];
    [date mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.monthLab.mas_bottom);
        make.left.right.equalTo(@0);
        make.height.equalTo(@(imgHeight *0.5));
    }];
    date.textAlignment = NSTextAlignmentCenter;
    date.font = [UIFont systemFontOfSize:17];
    date.text = @"17";
    self.dateLab = date;
    
    UILabel *time = [UILabel new];
    [diaryCalBgrImg addSubview:time];
    [time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(@0);
        make.top.equalTo(self.dateLab.mas_bottom);
    }];
    time.textAlignment = NSTextAlignmentCenter;
    time.font = [UIFont systemFontOfSize:10];
    time.text = @"星期四 12:00";
    self.timeLab = time;
    
//    UIImageView *pickImg = [UIImageView new];
//    pickImg.userInteractionEnabled = YES;
//    [bgrImg addSubview:pickImg];
//    [pickImg mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.bottom.equalTo(@0);
//        make.leading.mas_equalTo(diaryCalBgrImg.mas_trailing);
//        make.width.mas_equalTo(diaryCalBgrImg.mas_width);
//    }];
    
    UIButton *weatherBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [weatherBtn setBackgroundImage:[UIImage imageNamed:@"diary-weather-face-bg"] forState:UIControlStateNormal];
    [weatherBtn setBackgroundImage:[UIImage imageNamed:@"diary-weather-face-select-bg"] forState:UIControlStateHighlighted];
    [bgrImg addSubview:weatherBtn];
    [weatherBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(@0);
        make.leading.mas_equalTo(diaryCalBgrImg.mas_trailing);
        make.width.mas_equalTo(diaryCalBgrImg.mas_width);
    }];
    
    UIButton *cameraBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [cameraBtn setBackgroundImage:[UIImage imageNamed:@"diary-photo-bg"] forState:UIControlStateNormal];
    [bgrImg addSubview:cameraBtn];
    [cameraBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(@0);
        make.leading.mas_equalTo(weatherBtn.mas_trailing);
        make.width.mas_equalTo(diaryCalBgrImg.mas_width);
    }];
    
    UIButton *soundBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [soundBtn setBackgroundImage:[UIImage imageNamed:@"diary-sound-button"] forState:UIControlStateNormal];
    [soundBtn setBackgroundImage:[UIImage imageNamed:@"diary-sound-select-button"] forState:UIControlStateHighlighted];
    [bgrImg addSubview:soundBtn];
    [soundBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(@0);
        make.leading.mas_equalTo(cameraBtn.mas_trailing);
        make.width.mas_equalTo(diaryCalBgrImg.mas_width);
    }];
    
    UITextView *diaryText = [UITextView new];
    [self addSubview:diaryText];
    [diaryText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgrImg.mas_bottom);
        make.leading.mas_equalTo(bgrImg.mas_leading);
        make.trailing.mas_equalTo(bgrImg.mas_trailing);
        make.bottom.equalTo(@-10);
    }];
    diaryText.text = @"jfwopjglwj";
    diaryText.backgroundColor = [UIColor clearColor];
//    diaryText.editable = NO;
    self.diaryTextV = diaryText;
}

@end
